import requests

if __name__ == '__main__':
    # 请求用户注册
    # get传参  定义字典
    url = 'http://127.0.0.1:8080/'
    res = {'username':'admin','password':'123','phone':110,"email":'admin@qq.com'}
    # params 指定get请求参数
    res1 = requests.get(url+'/stest/user/regist.action',params=res)
    print(res1.text)
    # post接口调用 用户登录
    resa = {'username':'zhangsan','password':'123'}
    res2 = requests.post(url+'stest/user/login.action',data=resa)
    print(res2.text)
    # post接口 raw类型
    res3 = requests.post(url+'stest/user/dataRegist',json=resa)
    print(res3.text)
    # 图片上传接口 form-data
    usr = {'username':'qizong'}
    file = {'pic':open('1.jpg',mode='rb')}
    usr1 = requests.post(url+'stest/user/upload.action',data=usr,files=file)
    print(usr1.text)